{include file="common/head"}
<head>
    <title>分类管理</title>
    <style>
    </style>
</head>
<body >
<div class="container-fluid">
    <div class="row">
        <div class="col-2" style="text-align: left;line-height: 50px;font-size: 2rem;" >
            分类管理
        </div>
        <div class="col-10">    
        </div>
    </div>    
    <table class="table table-sm table-hover table-striped table-bordered">
        <thead class="table-info">
            <th>序号</th>
            <th>分类名称</th>
            <th>说明</th>
            <th>排序</th>
            <th>录入人</th>
            <th>录入时间</th>
            <th>是否启用</th>
            <th>
                <a href="/index.php/cat/cat_add" alt="新增分类(New category)">
                <button type="button" class="btn btn-sm btn-primary">
                        <span class="bi-plus-lg" style="color:#fff;"></span>
                </button></a>

            </th>
        </thead>
        <tbody>
            {foreach $data as $k=>$kv}
            <tr>
                <td>{$k}</td>
                <td {if $kv['status']!=1} style="color:red;" {/if}>
                    {if $kv['deepth']==1}
                        <c style="margin-left:10px;"></c>|__
                    {elseif $kv['deepth']==2}
                        <c style="margin-left:20px;"></c>|__
                    {elseif $kv['deepth']==3}
                        <c style="margin-left:40px;"></c>|__
                    {/if}
                    {$kv['name']}
                    
                </td>
                <td>{$kv['title']}</td>
                <td>{$kv['sort']} </td>
                <td>{$kv['creater_name']}</td>
                <td>{$kv['create_time']}</td>
                {if $kv['status']==1}
                    <td>{$kv['status_name']}</td>
                {else if $kv['status']==2}    
                    <td style="text-decoration:line-through;color:red;">{$kv['status_name']}</td>
                {/if}
                <td>
                    <a href="/index.php/cat/edit/id/{$kv['id']}">
                        <button type="button" class="btn btn-sm btn-info"><span class="bi-pencil" ></span></button>
                    </a> 

                    {if $kv['status']==2}
                    <button type="button" class="btn btn-sm btn-dark cat_del" cat_id="{$kv['id']}">
                        <span class="bi-x" ></span>
                    </button>

                    {/if}
                </td>
            </tr>
            {/foreach}

        </tbody>    
    </table>
</div>

</body>

<script type="text/javascript">
  $(function(){
    $('.cat_del').on('click',function(){
        var cat_id=$(this).attr('cat_id');
            //询问框

        layer.confirm('是否确定删除项目?', {
          btn: ['确定删除','再检查一下'] //按钮
        }, function(){

            $.ajax({
                url:'/index.php/cat/del',
                type:'post',
                data:{id:cat_id},
                success:function(res){
                    if(res.code){
                        layer.msg('删除成功!');
                        location.reload();
                    }else{
                        layer.msg(res.msg);
                    }
                     
                },
                fail:function(res){
                    layer.msg(res.code+'failed!');
                }
            });

            e.preventDefault(); 
            
        }, function(){
            layer.msg('操作取消！');
            return false;
            e.preventDefault(); //阻止冒泡
        }); 


    })
  })

</script>


</body>
</html>
